package pl.softech.gpw.candles.editor.dad;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

import pl.softech.gpw.candles.editor.CandlestickWidget;

public class CWidgetTransferable implements Transferable {

    public static DataFlavor DATA_FLAVOR = new DataFlavor(CandlestickWidget.class, "CandlestickWidget");

    private CandlestickWidget widget;

    public CWidgetTransferable(CandlestickWidget widget) {
        this.widget = widget;
    }

    @Override
    public DataFlavor[] getTransferDataFlavors() {
        return new DataFlavor[] { DATA_FLAVOR };
    }

    @Override
    public boolean isDataFlavorSupported(DataFlavor flavor) {
        
        return flavor == DATA_FLAVOR;
    }

    @Override
    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
        return widget;
    }

}
